<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('服务商划拨、撤销机具申请信息列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label style="width: 100px;">订单编号：</label>
                                <input type="text" name="orderNum"/>
                            </li>
                            <li>
                                <label style="width: 100px;">服务商编号：</label>
                                <input type="text" name="xagentNum"/>
                            </li>
                            <li>
                                <label style="width: 100px;">服务商名称：</label>
                                <input type="text" name="xagentName"/>
                            </li>
                            <li>
                                <label style="width: 100px;">申请类型：</label>
                                <select name="applyType">
                                    <option value="">所有</option>
                                    <option value="0">划拨</option>
                                    <option value="1">撤机</option>
                                </select>
                            </li>
                            <li>
                                <label style="width: 100px;">处理结果：</label>
                                <select name="result">
                                    <option value="">请选择</option>
                                    <option value="0">未处理</option>
                                    <option value="1">已处理</option>
                                    <option value="2">已作废</option>
                                </select>
                            </li>
                        </ul>
                        <ul>
                            <li class="select-time">
                                <label style="width: 100px;">申请日期：</label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始日期" name="params[beginAddTime]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束日期" name="params[endAddTime]"/>
                            </li>
                            <li class="select-time">
                                <label style="width: 100px;">结果日期：</label>
                                <input type="text" class="time-input" id="startTime1" placeholder="开始日期" name="params[beginAddTime1]"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime1" placeholder="结束日期" name="params[endAddTime1]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="terminal:pos:add">
                    <i class="fa fa-plus"></i> 划拨
                </a>
                <a class="btn btn-success" onclick="revoke()" shiro:hasPermission="terminal:pos:revoke">
                    <i class="fa fa-plus"></i> 撤机
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var terminalTypeDatas = [[${@dict.getType('terminal_type')}]];
        var editFlag = [[${@permission.hasPermi('terminal:pos:edit')}]];
        var removeFlag = [[${@permission.hasPermi('terminal:pos:remove')}]];
        var prefix = ctx + "terminal/pos";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "服务商划拨、撤销机具申请信息",
                columns: [
                {
                    field: 'orderNum',
                    title: '订单编号',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,12);
                    }
                },
                {
                    field: 'xagentNum',
                    title: '服务商编号'
                },
                {
                    field: 'xagentName',
                    title: '服务商名称',
                    formatter:function (value, row, index) {
                        return $.table.tooltip(value,4);
                    }
                },
                {
                    field: 'applyNum',
                    title: '申请数量'
                },
                {
                    field: 'posType',
                    title: '终端类型',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(terminalTypeDatas, value);
                    },
                    sortable: true
                },
                {
                    field: 'payMoney',
                    title: '首付',
                    formatter: function (value, row, index) {
                        return $.table.rmbFormatter(row.payMoney);
                    },
                    sortable: true
                },
                {
                    field: 'qmoney',
                    title: '欠款',
                    formatter: function (value, row, index) {
                        return $.table.rmbFormatter(row.qmoney);
                    },
                    sortable: true
                },
                {
                    field: 'applyType',
                    title: '申请类型',
                    formatter: function (value, row, index) {
                        if (row.applyType == 0 ){
                            return '<span style="color: green">划拨</span>';
                        } else if(row.applyType == 1 ){
                            return '<span style="color: blue">撤机</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    },
                    sortable: true
                },
                {
                    field: 'result',
                    title: '申请结果',
                    formatter: function (value, row, index) {
                        if (row.result == 0 ){
                            return '<span style="color: green">接受</span>';
                        } else if(row.result == 1 ){
                            return '<span style="color: red">拒绝</span>';
                        } else if(row.result == 2 ){
                            return '<span style="color: blue">待处理</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    },
                    sortable: true
                },
                {
                    field: 'applyDate',
                    title: '申请日期'
                },
                {
                    field: 'applyTime',
                    title: '申请时间'
                },
                {
                    field: 'handleRs',
                    title: '处理结果',
                    formatter: function (value, row, index) {
                        if (row.handleRs == 0 ){
                            return '<span style="color: green">未处理</span>';
                        } else if(row.handleRs == 1 ){
                            return '<span style="color: blue">已处理</span>';
                        } else if(row.handleRs == 2 ){
                            return '<span style="color: red">作废</span>';
                        } else {
                            return '<span style="color: red">未知</span>';
                        }
                    },
                    sortable: true
                },
                {
                    field: 'resultDate',
                    title: '处理日期'
                },
                {
                    field: 'resultTime',
                    title: '处理时间'
                },
                {
                    field: 'overdueDate',
                    title: '订单过期日期'
                },
                {
                    field: 'financeStatus',
                    title: '财务审核状态',
                    formatter: function (value, row, index) {
                        if (row.financeStatus == 0 ){
                            return '<span style="color: red">拒绝</span>';
                        } else if(row.financeStatus == 1 ){
                            return '<span style="color: blue">接受</span>';
                        } else if(row.financeStatus == 2 ){
                            return '<span style="color: red">财务待确认</span>';
                        } else if(row.financeStatus == 3 ){
                            return '<span style="color: red">无需财务确认</span>';
                        }else {
                            return '<span style="color: red">未知</span>';
                        }
                    },
                    sortable: true
                },
                {
                    field: 'financeDate',
                    title: '财务审核日期'
                },
                {
                    field: 'financeTime',
                    title: '财务审核时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if (row.handleRs=="0"){
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>作废</a>');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function revoke() {
            var url = prefix+"/revoke/";
            $.modal.open("添加撤机申请" , url, '800');
        }
    </script>
</body>
</html>